We were using that range for the extra buttons after left/right/middle,
while this is harmless for clients not handling extra buttons (we
used to translate those button events into scroll events in x11 anyway)
this will be unexpected for clients that do handle additional mouse
buttons themselves (eg. back/forward buttons present in some mice).
In order to remain compatible with X11, those need to be assigned from
button 8 onwards.
Also, include input.h, and stop using magic numbers here.
https://bugzilla.gnome.org/show_bug.cgi?id=758072
#include <xkbcommon/xkbcommon.h>
+#include <linux/input.h>
+
#include <sys/time.h>
#include <sys/mman.h>
+#define BUTTON_BASE (BTN_LEFT - 1) /* Used to translate to 1-indexed buttons */
+
typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
struct _GdkWaylandTouchData
switch (button)
{
- case 273:
- gdk_button = 3;
+ case BTN_LEFT:
+ gdk_button = GDK_BUTTON_PRIMARY;
+ break;
+ case BTN_MIDDLE:
+ gdk_button = GDK_BUTTON_MIDDLE;
break;
- case 274:
- gdk_button = 2;
+ case BTN_RIGHT:
+ gdk_button = GDK_BUTTON_SECONDARY;
break;
default:
- gdk_button = button - 271;
+ /* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
+ gdk_button = button - BUTTON_BASE + 4;
break;
}